package per.destiny.springtest.utils;

import org.dozer.DozerBeanMapper;
import org.dozer.Mapper;

public class BeanUtils {

    private static Mapper mapper = null;

    static {
        mapper = new DozerBeanMapper();
    }

    /**
     * Dozer可以实现深Copy，而Spring提供的BeanUtils只能浅Copy
     * @param source
     * @param target
     * @throws Exception
     */
    public static void copy(Object source,Object target) throws Exception{
        if(null == source){
            throw new Exception("source must not empty");
        }
        if(null == target){
            throw new Exception("target must not empty");
        }
        mapper.map(source,target);
    }
}
